import request from '../../../../../../public/js/common/api/api.js';

const PerfUrl = `${Utils.CurDomain.PerfUrl}/wkrpts`;
const UserUrl = `${Utils.CurDomain.SysAuthUrl}`;
const AccountUrl = Utils.CurDomain.AccountUrl;

const configuration = {
    contentType: 'application/json',
    dataType: 'json',
    async: true,
    dataFilter(data, type) {
        return data;
    }
}

/**
 * @file工作汇报API
 */
export default class WorkReportMainApi {

    /**
     * 工作汇报我提交的列表
     * @param {*} data 
     * @returns 
     */
    static getWkrptsSubmitedList(data) {
        return request.post(`${PerfUrl}/submited`, { "sort": "reportEndDate desc", ...data }, true, configuration);
    }

    /**
     * 我收到的工作汇报列表
     * @param {*} data 
     * @returns 
     */
    static getWkrptsReceivedList(data) {
        return request.post(`${PerfUrl}/received`, { "sort": "reportEndDate desc", ...data }, true, configuration);
    }

    /**
     * 添加我的工作汇报
     * @param {*} data 
     * @returns 
     */
    static addWkrptsBill(data) {
        return request.post(`${PerfUrl}`, data, { ajaxOptions: configuration }, true, configuration);
    }

    /**
     * 编辑工作汇报
     * @param {*} id 
     * @param {*} data 
     * @returns 
     */
    static updateWkrptsBill(id, data) {
        return request.put(`${PerfUrl}/${id}`, data, { ajaxOptions: configuration });
    }

    /**
     * 查看工作汇报详情
     * @param {*} id 
     * @returns 
     */
    static getWkrptsBillDetail(id) {
        return request.get(`${PerfUrl}/${id}`);
    }

    /**
     * 删除工作汇报
     * @param {*} id 
     * @returns 
     */
    static deleteWkrptsBill(id) {
        return request.delete(`${PerfUrl}/${id}`);
    }

    /**
    * 获取登录用户对应的职员信息
    * @returns 
    */
    static getLoginUserToStaff() {
        return request.get(`${AccountUrl}/accounts/eply`);
    }

    /**
    * 查询汇报员工上次所选汇报对象
    * @returns 
    */
    static getNextEmployees(rid) {
        return request.get(`${PerfUrl}/${rid}/rcps`);
    }

}